home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Keyframe Magazine 6
/
KeyFrame Magazine, Issue 6 - May-June 1998 WIN-MAC (David Warner)(1998).iso
/
mac
/
ParentBone
/
DanzParentBone.LS
next >
Wrap
Text File
|
1998-01-14
|
7KB
|
301 lines
//dan R's Parent anything motion plugin
// replacement for parent bone
// does alot more
//
// parent, unparent
// temperal offset (use with IK to make "drag behind" bones like tails and long ears.)
//example of info
//info("Object ",refobject.name," has ",refobject.pointcount," points.");
var refobjectname;
var refob;
var refobb;
var refobc;
var timeoffset;
var modifyposition;
var modifyrotation;
var parentonlyrotation;
var relativeposition;
var newparrt[3];
var newparrt3;
var newparrt4;
var newpos[3];
var newpos2;
var newpos4;
var c0,c1,c2,c3,c4,c5,c6;
var cur;
var curb;
var thisobject;
var thisobjectb;
var thistime;
var thisframe;
var startparent;
var stopparent;
var startparenttime;
var stopparenttime;
var refobname2;
var mythisobject;
create {
refobjectname="";
timeoffset = 0;
modifyposition = true;
modifyrotation = false;
parentonlyrotation = false;
relativeposition = false;
newparrt[]=0.0;
//newparrt3 = < 0.0 , 0.0 , 0.0 >;
//newparrt4 = < 0.0 , 0.0 , 0.0 >;
newpos[3]=0.0;
newpos2 = <0.0 , 0.0 , 0.0>;
//newpos4 = <0.0 , 0.0 , 0.0>;
startparent = 0;
stopparent = 9999;
startparenttime = 0.001;
stopparenttime = 0.001;
refobname2 = "";
mythisobject = 0;
setdesc("danz parent anything 1.3"); // set panel button text
}
options {
//display options requester
if(!reqbegin("parent bone - the revenge:"))
return; // no Panel Services plug-in
addtext ("danz parent bone plugin for lscript 1.3","");
addtext ("copyright 1997 dan ritchie","all rights reserved","");
addtext ("Shareware fee $20.00 US. Send to: Parent Bone","");
addtext ("PO BOX 621 Oldsmar FL. 34677-0621 USA","");
c0 = addcontrol(refobjectname,"current");
c1 = additems("select parent from list"); //adds a dropdown control to pick an object
//from a list of all objects
c2 = addcheckbox(modifyposition,"inheirit position");
c3 = addcheckbox(relativeposition,"allow motion relative to parent");
c5 = addcheckbox(parentonlyrotation,"use rotation from parent");
//c4 = addcheckbox(modifyrotation,"full rotation (don't work right)");
c6 = addcontrol(timeoffset,"temporal offset in frames (negative Ok)");
c7 = addcontrol(startparent,"start parenting at frame");
c8 = addcontrol(stopparent,"stop parenting at frame");
reqpost();
// if(( refobject = getvalue(c1)) == nil)
// return;
refobject = getvalue(c1);
refobname2 = getvalue(c0);
modifyposition = getvalue(c2);
relativeposition = getvalue(c3);
modifyrotation = 0; //getvalue(c4);
parentonlyrotation = getvalue(c5);
timeoffset = getvalue(c6);
startparent = getvalue(c7);
stopparent = getvalue(c8);
reqend();
if (refobject != nil)
{
refobjectname = refobject.name;
}
else
{
refobjectname = refobname2;
}
return;
}
process: thisobject,thisframe,thistime
{
//this is here so i can remember it...
//get(attribute,time);
//set(attribute,value);
//this function allows you to set the specified 'attribute'
//(POSITION, ROTATION, SCALING) to the provided vector 'value'
//get time
timeminusoffset = thistime - (timeoffset/30); //time offset;
startparenttime = (startparent / 30);
stopparenttime = (stopparent / 30);
// start and stop parenting...
if (timeminusoffset < startparenttime) {timeminusoffset = startparenttime;}
if (timeminusoffset > stopparenttime) {timeminusoffset = stopparenttime;}
//get position of parent
refob = getfirstitem(refobjectname);
newpos2 = refob.param(WPOSITION,timeminusoffset);
//newpos2 = refob.getWorldPosition(timeminusoffset);
newpos[1] = newpos2.x;
newpos[2] = newpos2.y;
newpos[3] = newpos2.z;
//get rotation of parent
if (parentonlyrotation == true)
{
refobb = getfirstitem(refobjectname);
newparrt3 = refobb.param(ROTATION,timeminusoffset);
curb = thisobject.get(ROTATION,thistime);
newparrt[1] = newparrt3.x + curb.x; //actually h, p, b
newparrt[2] = newparrt3.y + curb.y;
newparrt[3] = newparrt3.z + curb.z;
}
//get rotation of all parent objects
if (modifyrotation == true)
{
curb = thisobject.get(ROTATION,thistime);
newparrt[1] = curb.x; //actually h, p, b
newparrt[2] = curb.y;
newparrt[3] = curb.z;
//loop until read all parents
//so what i need to do is...
//go until thisobject = refobc
refoc=nil;
mythisobject=nil;
refobc = getfirstitem(refobjectname);
mythisobject = thisobject.objID;
while (refobc.name != mythisobject.name )
{
if ( refobc != nil )
{
info (" obj 1: ", refobc.name , " obj 2: " , mythisobject.name);
newparrt4 = refobc.param(ROTATION,timeminusoffset);
newparrt[1] = newparrt[1] + newparrt4.x;
newparrt[2] = newparrt[2] + newparrt4.y;
newparrt[3] = newparrt[3] + newparrt4.z;
}
refobc = refobc.next();
}
}
//only modify position if user wants it...
if (modifyposition == true)
{
//caculate position relative to parent
if (relativeposition == 1)
{
cur = thisobject.get(POSITION,thistime);
newpos[1] = newpos2.x + cur.x;
newpos[2] = newpos2.y + cur.y;
newpos[3] = newpos2.z + cur.z;
}
//set position
thisobject.set(POSITION,<newpos[1],newpos[2],newpos[3]>);
}
//modify rotation if user wants it...
if ((parentonlyrotation == true) || (modifyrotation == true))
{
//set Rotation from parent
thisobject.set(ROTATION,<newparrt[1],newparrt[2],newparrt[3]>);
}
//end process:
}
save: what, io
{
if(what == SCENEMODE) // processing an ASCII scene file
{
io.writeln("refobjectname::",refobjectname);
io.writeln("timeoffset ",timeoffset);
io.writeln("modifyposition ",modifyposition);
io.writeln("modifyrotation ",modifyrotation);
io.writeln("parentonlyrotation ",parentonlyrotation);
io.writeln("relativeposition ",relativeposition);
io.writeln("startparent ",startparent);
io.writeln("stopparent ",stopparent);
}
}
load: what, io
{
var line = "";
var items[2];
if(what == SCENEMODE)
{
line = io.read();
items=parse("::",line);
refobjectname = items[2];
line = nil;
line = io.read();
items = parse(" ",line);
timeoffset = integer(items[2]);
line = nil;
line = io.read();
items = parse(" ",line);
modifyposition = integer(items[2]);
line = nil;
line = io.read();
items = parse(" ",line);
modifyrotation = integer(items[2]);
line = nil;
line = io.read();
items = parse(" ",line);
parentonlyrotation = integer(items[2]);
line = nil;
line = io.read();
items = parse(" ",line);
relativeposition = integer(items[2]);
line = nil;
line = io.read();
items = parse(" ",line);
startparent = integer(items[2]);
line = nil;
line = io.read();
items = parse(" ",line);
stopparent = integer(items[2]);
}
}